<script setup lang="ts">
import { ref, onMounted } from "vue";
import Top from "./components/top/index.vue";
import Sex from "./components/sex/index.vue";
import Age from "./components/age/index.vue";
import Tourist from "./components/tourist/index.vue";
import Map from "./components/map/index.vue";
import Line from "./components/line/index.vue";
import Rank from "./components/rank/index.vue";
import Year from "./components/year/index.vue";
import Count from "./components/count/index.vue";
let screen = ref();
// onMounted
onMounted(() => {
  screen.value.style.transform = `scale(${getSacle()}) translate(-50%,-50%)`;
});
window.onresize = () => {
  if (screen.value) {
    screen.value.style.transform = `scale(${getSacle()}) translate(-50%,-50%)`;
  }
};
const getSacle = (w = 1920, h = 1080) => {
  let ww = window.innerWidth / w;
  let wh = window.innerHeight / h;
  return ww < wh ? ww : wh;
};
</script>

<template>
  <div class="container">
    <div class="screen" ref="screen">
      <div class="top">
        <Top />
      </div>
      <div class="bottom">
        <div class="left">
          <Tourist class="tourist"></Tourist>
          <Sex class="sex"></Sex>
          <Age class="age"></Age>
        </div>
        <div class="center">
          <Map class="map"></Map>
          <Line class="line"></Line>
        </div>
        <div class="right">
          <Rank class="rank"></Rank>
          <Year class="year"></Year>
          <Count class="count"></Count>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.container {
  width: 100vw;
  height: 100vh;
  background: url(./images/bg.png);
  background-size: cover;

  .screen {
    width: 1920px;
    height: 1080px;
    transform-origin: left top;
    position: fixed;
    top: 50%;
    left: 50%;

    .top {
      width: 100%;
      height: 40px;
    }

    .bottom {
      display: flex;

      .left {
        display: flex;
        flex-direction: column;
        flex: 1;
        height: 1040px;

        .tourist {
          flex: 1.2;
        }

        .sex {
          flex: 1;
        }

        .age {
          flex: 1;
        }
      }

      .center {
        flex: 1.5;
        display: flex;
        flex-direction: column;
        .map {
          flex: 4;
        }
        .line {
          flex: 1;
        }
      }

      .right {
        flex: 1;
        display: flex;
        flex-direction: column;
        .rank {
          flex: 1.5;
        }
        .year {
          flex: 1;
        }
        .count {
          flex: 1;
        }
      }
    }
  }
}
</style>
